#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
struct ListNode {
    int val;
    struct ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};
struct ListNode* FindMiddle(struct ListNode* head)
{
    struct ListNode* fast, * slow;
    fast = slow = head;
    while (fast && fast->next)
    {
        slow = slow->next;
        fast = fast->next->next;
    }
    return slow;
}
struct ListNode* reverseList(struct ListNode* head)
{
    struct ListNode* newhead = NULL;
    struct ListNode* cur = head;
    while (cur)
    {
        struct ListNode* next = cur->next;
        cur->next = newhead;
        newhead = cur;
        cur = next;
    }
    return newhead;

}
class PalindromeList {
public:
    bool chkPalindrome(ListNode* A) {
        // write code here
        struct ListNode* Midhead = FindMiddle(A);
        struct ListNode* newList = reverseList(Midhead);
        struct ListNode* curA = A;
        struct ListNode* curB = newList;
        while (curA && curB)
        {
            if (curA->val != curB->val)
            {
                return false;
            }
            else
            {
                curA = curA->next;
                curB = curB->next;
            }

        }
        return true;
    }
};
int main()
{
    return 0;
}